import React from 'react'
import { CoverView } from '@tarojs/components'

import styles from './index.module.scss'

// 首页选择项目modal
export default function ProjectViewModal(props) {
  const { onModalClick, projectData } = props;

  // 替换 project_name 的值
  const updatedProjectData = projectData?.map((item) => {
    if (item.project_name === '母婴儿童大健康产业园') {
      return { ...item, project_name: '济南科技产业创新示范园' };
    }
    return item;
  });

  // 点击事件
  const itemClick = (item) => {
    onModalClick(item);
  };

  return (
    <CoverView className={styles.viewModal}>
      <CoverView className={styles.container}>
        {updatedProjectData?.length > 0
          ? updatedProjectData.map((item, index) => {
              return (
                <CoverView
                  key={index.toString()}
                  className={styles.text}
                  onClick={() => itemClick(item)}
                >
                  {item.project_name}
                </CoverView>
              );
            })
          : null}
      </CoverView>
    </CoverView>
  );
}
